<?php 

/*********************************************************************
*  Class : Flow
*  Function : 
*  Author :  joharijumali
*  Description: Class for Getting Application Flow
**********************************************************************/

class Flow{

    /**
     * sidebar function
     * Create sidebar
     * @return string
     * @author joharijumali
     **/

    public static function next($flow,$state) {

    	$path = URI::segment(2).'/'.URI::segment(3).'/'.URI::segment(4);

    	$page = Console_Page::where('smp_modul','=',URI::segment(2))
                            ->where('smp_controller','=',URI::segment(3))
                            ->where('smp_action','=',URI::segment(4))->first();
                            
    	if($page){
    		try{

                if($state == null):
                    $state = 0;
                endif;

	    		$currentStep = Console_Rule::where('sfr_page','=',$page->smp_id)
                                            ->where('sfr_state','=',$state)
                                            ->where('sf_id','=',$flow)
                                            ->where('sur_id','=',Auth::user()->sur_id)
                                            ->first();

	    		return $currentStep->sfr_next;

    		}catch (Exception $e) {
    			Log::write('Flow', 'Status Retrieving Failed: ' . $e->getMessage());
    		}
    	}else{
    		Log::write('Flow', 'Page Not Exist: ');
    	}

    }



 }
 ?>